package cn.monkey.state.scheduler.disruptor;

import cn.monkey.state.scheduler.EventPublishScheduler;
import cn.monkey.state.scheduler.EventPublishSchedulerFactory;
import cn.monkey.state.scheduler.SimpleEventPublishSchedulerFactory;

import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;

public class RingBufferEventPublishSchedulerFactory implements EventPublishSchedulerFactory {

    protected RingBufferConfig ringBufferConfig = RingBufferConfig.newBuilder().build();

    protected ThreadFactory threadFactory = Executors.defaultThreadFactory();

    public void setRingBufferConfig(RingBufferConfig ringBufferConfig) {
        this.ringBufferConfig = ringBufferConfig;
    }

    @Override
    public EventPublishScheduler create(long id) {
        return new RingBufferEventPublisherScheduler(id, this.threadFactory, this.ringBufferConfig);
    }

    @Override
    public void setThreadFactory(ThreadFactory threadFactory) {
        this.threadFactory = threadFactory;
    }
}
